package com.ericom.dao.hibernate;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.ericom.dao.ProductDao;
import com.ericom.model.Product;
@Repository("productDao")
public class ProductDaoHibernate extends GenericDaoHibernate<Product, Long>
		implements ProductDao {

	public ProductDaoHibernate() {
		super(Product.class);

	}

	public List<Product> findByCategory(Long catid) {
		return this.getHibernateTemplate().find(
				"select p from Product p left join p.categories c where c.id=?",
				catid);

	}

	public List<Product> findByOnline() {
		return this.getHibernateTemplate().find("from Product where online=1");
	}

	public List<Product> findByOffline() {
		return this.getHibernateTemplate().find("from Product where online=0");

	}

}
